{% extends 'layout.html' %}
{% load static %}
{% block css %}
    <link rel="stylesheet" href="{% static 'plugin/editor-md/css/editormd.min.css' %}">

{% endblock %}

{% block content %}
    <div class="luffy-container">

        <form class="form-horizontal" method="post" novalidate>
            {% csrf_token %}

            {% for field in form %}
                <div class="form-group">
                    {% if field.name == 'content' %}
                        <label class="col-sm-2 control-label">{{ field.label }}</label>
                        <div class="col-sm-8">
                            <div id="editor">
                                {{ field }}
                            </div>
                            <span style="color: red;">{{ field.errors.0 }}</span>
                        </div>
                    {% else %}
{#                        <label class="col-sm-2 control-label">{{ field.label }}</label>#}
                        <label class="col-sm-2 control-label">{{ field.label }}</label>
                        <div class="col-sm-8">
                            {{ field }}
                            <span style="color: red;">{{ field.errors.0 }}</span>
                        </div>
                    {% endif %}
                </div>
            {% endfor %}
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-8">
                    <input type="submit" value="保 存" class="btn btn-primary">
                </div>
            </div>
        </form>
    </div>

{% endblock %}


{% block js %}
    <script src="{% static 'plugin/editor-md/editormd.js' %}"></script>
    <script>
        {#var WIKI_UPLOAD_URL = "{% url 'wiki_upload_local' project_id=request.tracer.project.id %}";#}
        $(function () {
            initEditorMd();
        });
         /*
        初始化markdown编辑器（textare转换为编辑器）
         */
        function initEditorMd() {
            editormd('editor', {
                placeholder: "请输入内容",
                height: 500,
                path: "{% static 'plugin/editor-md/lib/' %}",
                imageUpload:false,
                {#imageFormats:["jpg",'jpeg','png','gif'],#}
                {#imageUploadURL:WIKI_UPLOAD_URL#}
            })
        }
    </script>
{% endblock %}